package cn.tedu.aop.log.service.impl;

import cn.tedu.aop.log.mapper.OperationLogMapper;
import cn.tedu.aop.log.pojo.OperationLog;
import cn.tedu.aop.log.service.OperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class OperationLogServiceImpl implements OperationLogService {

    @Autowired
    private OperationLogMapper operationLogMapper;

    /**
     * @Async注解描述的方法相当于一个异步切入点方法，
     * 此方法在执行时，会有springboot中的线程池内部的线程来执行
     * @param operationLog
     */
    @Async
    @Override
    public void save(OperationLog operationLog) {
        System.out.println("OperationLogServiceImpl.thread.name->"+Thread.currentThread().getName());
        try{Thread.sleep(5000);}catch (Exception e){}
        operationLogMapper.insert(operationLog);
    }
}
